package com.cosina.game.tetri;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;

import com.cosina.game.tetri.engine.Box;
import com.cosina.game.tetri.engine.Point;
import com.cosina.game.tetri.engine.impl.BoxImpl;

public class Tetri extends Activity {
	 Box box;
	 TetriBoxView boxView;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        boxView = (TetriBoxView)findViewById(R.id.boxView);
        box = new BoxImpl(Point.c(10, 15));
        boxView.setBox(box);
        box.fill();
        
        
        boxView.postDelayed(timeElapse, 1000);
    }
    
    Runnable  timeElapse = new Runnable(){
    	public void run(){
    		if(box.isOver() == false){
    			box.handleTimePassEvent();
    			boxView.postInvalidate();
    			boxView.postDelayed(this, 1000);
    		}
    	}
    };
}